package qf.com.servlet;

import qf.com.domain.Profile;
import qf.com.domain.User;
import qf.com.service.UserService;
import qf.com.service.impl.UserServiceimpl;
import qf.com.service.impl.longServiceimpl;
import qf.com.service.longService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * projectName:kaoshi
 * author:jcl
 * time:2022/5/27 12:48
 * description:
 */
@WebServlet("/long")
public class Long extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserService userService = new UserServiceimpl();

        String yonghuming = request.getParameter("yonghuming");
        String mima = request.getParameter("mima");

        longService longService = new longServiceimpl();
        User denglu = longService.denglu(yonghuming, mima);

        if(denglu!= null){
            Profile chazhao = userService.chazhao(yonghuming);

            request.setAttribute("profile",chazhao);
            request.getRequestDispatcher("dangan.jsp").forward(request,response);
        }
        request.getRequestDispatcher("long.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}